package com.kaf.ai.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

public class AiConfig {

    @Bean
    @ConfigurationProperties(prefix = "ai.deepseek")
    public AiProperties deepSeekProperties() {
        return new AiProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "ai.tongyi")
    public AiProperties tongyiProperties() {
        return new AiProperties();
    }

    @Bean
    public WebClient webClient() {
        return WebClient.builder()
                .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(10 * 1024 * 1024)) // 10MB
                .build();
    }

    // 用于存储每个供应商的配置
    public static class AiProperties {
        private String apiKey;
        private String baseUrl;
        private String model;
        private Integer timeoutSeconds = 60;

        // Getters and Setters
        public String getApiKey() { return apiKey; }
        public void setApiKey(String apiKey) { this.apiKey = apiKey; }
        public String getBaseUrl() { return baseUrl; }
        public void setBaseUrl(String baseUrl) { this.baseUrl = baseUrl; }
        public String getModel() { return model; }
        public void setModel(String model) { this.model = model; }
        public Integer getTimeoutSeconds() { return timeoutSeconds; }
        public void setTimeoutSeconds(Integer timeoutSeconds) { this.timeoutSeconds = timeoutSeconds; }
    }
}